package com.xc.smart.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xc.smart.annotation.Login;
import com.xc.smart.annotation.LoginUser;
import com.xc.smart.entity.Goods;
import com.xc.smart.entity.User;
import com.xc.smart.entity.dto.GoodsDto;
import com.xc.smart.service.GoodsService;
import com.xc.smart.utlis.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author mtl
 * 2021/6/23
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Resource
    GoodsService goodsService;

    @Login
    @RequestMapping("/list")
    public R selectList(@LoginUser User user,
                        @RequestParam(value = "page",defaultValue = "1")Integer page){
        List<Goods> list = goodsService.list();
        return R.ok().put("list",list);
    }

    @Login
    @RequestMapping("/spike")
    public R spike(@LoginUser User user, GoodsDto dto){
        R r = goodsService.spike(user, dto);
        return r;
    }

    @Login
    @RequestMapping("/buy")
    public R buy(@LoginUser User user, GoodsDto dto){
        R r = goodsService.buy(user, dto);
        return r;
    }



}
